package com.itbaima.service.impl;

import com.itbaima.mapper.SalaryStandardMapper;
import com.itbaima.pojo.entity.HrSalary;
import com.itbaima.pojo.entity.Salary;
import com.itbaima.service.SalaryStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class SalaryStandardServiceImpl implements SalaryStandardService {

    @Autowired
    private SalaryStandardMapper salaryStandardMapper;



    @Override
    public void insertSalaryStandard(Salary salary) {
        // 调用 Mapper 插入数据
        salary.setSalary_id(salary.getDepartment_id()-3);
        int rowsAffected = salaryStandardMapper.insertSalary(salary);

        if (rowsAffected > 0) {
            System.out.println("薪酬标准插入成功！");
        } else {
            System.out.println("薪酬标准插入失败！");
        }
    }

    @Override
    public void submit2(List<HrSalary> salary) {


        for(HrSalary onesalary :salary)
        {
        salaryStandardMapper.update(onesalary);
}
    }

//    @Override
//    public Double getTotalSalaryByDepartmentId(Long departmentId) {
//        // 根据 department_id 查找对应的薪酬标准
//        Salary salary = salaryRepository.findByDepartmentId(departmentId);
//        if (salary != null) {
//            return salary.getTotalSalary();
//        }
//        return null;  // 返回null或根据需要抛出异常
//    }
}

